<template>
  <div>
       <div class="order-container bg-fff f30  color-000 border-bottom">
                    <span :class="{'span-icon-xinhao':entity.isRequired}">{{entity.displayName}}</span>
                    <input :maxlength="entity.textMaxLength" type="text" v-model="value"
                    @focus="onFocus('gameAccount')" @blur="onBlur('gameAccount');" @input="checkError()"
                    :placeholder="'请输入'+entity.displayName" >
        </div>
        <div class="contaner-qq" v-if="qqGame && qqGameAccount">
            <p class="f24 border-bottom ">注：如果您出售的QQ游戏帐号和登入5173帐号一致，交易成功后，您的5173帐号将会一起被出售，导致您人财两空，请您注意。</p>
        </div>
        <div class="contaner-qq" v-if="qqGame && qqGamePwd">
            <p class="f24 border-bottom">注：由于腾讯异地登入会出现冻结保护，建议您先到QQ安全中心绑定手机再进行发布。</p>
        </div>
        <div class="contaner-qq fw border-bottom" :id="entity.fixedField" v-if="error">
             <p class="f24">请输入{{entity.displayName}}</p>
        </div>
  </div>
</template>
<script type="text/javascript">
  export default{
    props:['saveFixed','entity','qqGame'],
    data(){
      return{
        id:'fixedComponent',
        value:'',
        error:false,
        game_type: this.$route.query.game_type,
        qqGameAccount:false,//QQ游戏账号提示判断
        qqGamePwd:false,//QQ游戏密码提示判断
      }
    },
    watch: {
      value(val) {
        this.saveValue(val);
      }
    },
    created(){
       this.$on('showFixedError',(list)=>{
         this.error = list[this.entity.fixedField];
       });
       this.$on('setValue',(val)=>{
         this.value = val[this.entity.fixedField];
       })
    },
    methods:{
      onBlur(){
         if(this.entity.fixedField == "gameAccount"){
            this.qqGameAccount = false
         }else if(this.entity.fixedField == "gamePwd"){
            this.qqGamePwd = false
         }

      },
      onFocus() {
          if(this.entity.fixedField == "gameAccount" && this.game_type == 1){
              this.qqGameAccount = true
          }else if(this.entity.fixedField == "gamePwd" && this.game_type == 1 ){
              this.qqGamePwd = true
          }
      },
      saveValue(val){
          if (val) {
              this.error = false;
          };
          if (this.saveFixed) {
              this.saveFixed({
                 fixedField:this.entity.fixedField,
                 value:val
              });
          };
      },
      checkError(){

        if (this.value === ' ') {
            this.value = this.value.replace(/\s/ig, '')
        }
        this.show = this.$parent.fixedRequired[this.entity.fixedField];
      }
    }
  }
</script>
<style src="css/common/publish-cl.css" ></style>
